namespace ACRSAP.Administration.Projects
{
    using ASPNET.StarterKit.IssueTracker.BusinessLogicLayer;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Diagnostics;
    using System.Runtime.CompilerServices;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using ACRSAP.Administration.Projects.UserControls;

    public class EditProject : Page
    {
        [AccessedThroughProperty("CancelButton")]
        private Button _CancelButton;
        [AccessedThroughProperty("ctlCategories")]
        private ProjectCategories _ctlCategories;
        [AccessedThroughProperty("ctlCustomFields")]
        private ProjectCustomFields _ctlCustomFields;
        [AccessedThroughProperty("ctlPriority")]
        private ProjectPriorities _ctlPriority;
        [AccessedThroughProperty("ctlProjectDescription")]
        private ProjectDescription _ctlProjectDescription;
        [AccessedThroughProperty("ctlProjectMembers")]
        private ProjectMembers _ctlProjectMembers;
        [AccessedThroughProperty("ctlProjectStatus")]
        private ProjectStatus _ctlProjectStatus;
        [AccessedThroughProperty("DeleteButton")]
        private Button _DeleteButton;
        [AccessedThroughProperty("SaveButton")]
        private Button _SaveButton;
        private object designerPlaceholderDeclaration;

        public EditProject()
        {
            base.Init += new EventHandler(this.Page_Init);
            base.Load += new EventHandler(this.Page_Load);
        }

        public void CancelButton_Click(object s, EventArgs e)
        {
            this.Response.Redirect("~/Administration/Projects/ProjectList.aspx");
        }

        public void DeleteButton_Click(object s, EventArgs e)
        {
            Project.DeleteProject(this.ProjectId);
            this.Response.Redirect("~/Administration/Projects/ProjectList.aspx");
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
        }

        private void Page_Init(object sender, EventArgs e)
        {
            this.InitializeComponent();
        }

        private void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.ProjectId = int.Parse(this.Request.QueryString["id"]);
            }
            this.ctlProjectDescription.ProjectId = this.ProjectId;
            this.ctlProjectMembers.ProjectId = this.ProjectId;
            this.ctlCategories.ProjectId = this.ProjectId;
            this.ctlProjectStatus.ProjectId = this.ProjectId;
            this.ctlPriority.ProjectId = this.ProjectId;
            this.ctlCustomFields.ProjectId = this.ProjectId;
            if (!this.Page.IsPostBack)
            {
                this.ctlProjectDescription.Initialize();
                this.ctlProjectMembers.Initialize();
                this.ctlCategories.Initialize();
                this.ctlProjectStatus.Initialize();
                this.ctlPriority.Initialize();
                this.ctlCustomFields.Initialize();
            }
            this.DeleteButton.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this project?');");
        }

        public void SaveButton_Click(object s, EventArgs e)
        {
            if (this.Page.IsValid)
            {
                this.ctlProjectDescription.Update();
                this.Response.Redirect("~/Administration/Projects/ProjectList.aspx");
            }
        }

        protected virtual Button CancelButton
        {
            get
            {
                return this._CancelButton;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._CancelButton != null)
                {
                    this._CancelButton.Click -= new EventHandler(this.CancelButton_Click);
                }
                this._CancelButton = value;
                if (this._CancelButton != null)
                {
                    this._CancelButton.Click += new EventHandler(this.CancelButton_Click);
                }
            }
        }

        protected virtual ProjectCategories ctlCategories
        {
            get
            {
                return this._ctlCategories;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._ctlCategories != null)
                {
                }
                this._ctlCategories = value;
                if (this._ctlCategories != null)
                {
                }
            }
        }

        protected virtual ProjectCustomFields ctlCustomFields
        {
            get
            {
                return this._ctlCustomFields;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._ctlCustomFields != null)
                {
                }
                this._ctlCustomFields = value;
                if (this._ctlCustomFields != null)
                {
                }
            }
        }

        protected virtual ProjectPriorities ctlPriority
        {
            get
            {
                return this._ctlPriority;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._ctlPriority != null)
                {
                }
                this._ctlPriority = value;
                if (this._ctlPriority != null)
                {
                }
            }
        }

        protected virtual ProjectDescription ctlProjectDescription
        {
            get
            {
                return this._ctlProjectDescription;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._ctlProjectDescription != null)
                {
                }
                this._ctlProjectDescription = value;
                if (this._ctlProjectDescription != null)
                {
                }
            }
        }

        protected virtual ProjectMembers ctlProjectMembers
        {
            get
            {
                return this._ctlProjectMembers;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._ctlProjectMembers != null)
                {
                }
                this._ctlProjectMembers = value;
                if (this._ctlProjectMembers != null)
                {
                }
            }
        }

        protected virtual ProjectStatus ctlProjectStatus
        {
            get
            {
                return this._ctlProjectStatus;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._ctlProjectStatus != null)
                {
                }
                this._ctlProjectStatus = value;
                if (this._ctlProjectStatus != null)
                {
                }
            }
        }

        protected virtual Button DeleteButton
        {
            get
            {
                return this._DeleteButton;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._DeleteButton != null)
                {
                    this._DeleteButton.Click -= new EventHandler(this.DeleteButton_Click);
                }
                this._DeleteButton = value;
                if (this._DeleteButton != null)
                {
                    this._DeleteButton.Click += new EventHandler(this.DeleteButton_Click);
                }
            }
        }

        public int ProjectId
        {
            get
            {
                if (this.ViewState["ProjectId"] == null)
                {
                    return -1;
                }
                return IntegerType.FromObject(this.ViewState["ProjectId"]);
            }
            set
            {
                this.ViewState["ProjectId"] = value;
            }
        }

        protected virtual Button SaveButton
        {
            get
            {
                return this._SaveButton;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._SaveButton != null)
                {
                    this._SaveButton.Click -= new EventHandler(this.SaveButton_Click);
                }
                this._SaveButton = value;
                if (this._SaveButton != null)
                {
                    this._SaveButton.Click += new EventHandler(this.SaveButton_Click);
                }
            }
        }
    }
}

